package com.fzrskj.cloud.free.core.tool;

import com.fzrskj.cloud.free.core.utils.CloudContextUtils;
import ms.core.support.Session;
import ms.core.tool.SessionTool;
import ms.core.tool.StrTool;

/**
 * CSessionTool.
 *
 * @author zj.
 *         Created on 2018/8/30 0030.
 */
public class CSessionTool extends SessionTool {
    private static String formatSid(String sid) {
        return sid = String.valueOf(CloudContextUtils.getAgentId()) + "-" + sid;
    }

    public static void setLoginSessionCloud(String sid, Session ssn){
        if (StrTool.isBlankStr(sid)) {
            return;
        }

        sid = formatSid(sid);

        setLoginSession(sid, ssn);
    }

    public static void delSessionCloud(String sid){
        delSession(formatSid(sid));
    }

    public static Session getSessionCloud(String sid){
        return getSession(formatSid(sid));
    }

    public static void setCheckCodeCloud(String sid, String code){
        setCheckCode(formatSid(sid), code);
    }

    public static void newSessionCloud(String sid){
        newSession(formatSid(sid));
    }

    public static String getAccountCloud(String sid){
        return getAccount(formatSid(sid));
    }

    public static int getAccountTypeCloud(String sid){
        return getAccountType(formatSid(sid));
    }

    public static int getUidCloud(String sid){
        return getUid(formatSid(sid));
    }

    public static String getDataCloud(String sid){
        return getData(formatSid(sid));
    }
}
